#include "addentdialog.h"

AddEntDialog::AddEntDialog(QVector<AED_Archtype*> *archs, QWidget *parent) :
    QDialog(parent),m_archs(archs)
{

    QVBoxLayout *main_layout = new QVBoxLayout;
    this->setLayout(main_layout);

    archbox = new QComboBox;
    for(int i=0;i<m_archs->size();i++){
        if(i==0)
            curr_arch=((*m_archs)[i]);
        archbox->addItem((*m_archs)[i]->GetName());
    }

    main_layout->addWidget(archbox);
    QHBoxLayout *button_layout = new QHBoxLayout;

    QPushButton *okButton = new QPushButton("OK");
    QPushButton *cancelButton = new QPushButton("Cancel");
    button_layout->addWidget(okButton);
    button_layout->addWidget(cancelButton);
    button_layout->setAlignment(Qt::AlignRight);
    main_layout->addLayout(button_layout);

    connect(archbox,SIGNAL(currentIndexChanged(int)),this,SLOT(SetArchtype(int)));
    connect(okButton, SIGNAL(clicked()),
             this, SLOT(accept()));
    connect(cancelButton, SIGNAL(clicked()),
             this, SLOT(reject()));
}

AED_Archtype* AddEntDialog::GetArchtype(){
    return curr_arch;
}

void AddEntDialog::SetArchtype(int index){
    curr_arch = ((*m_archs)[index]);
}
